#include"../source/server.hpp"


std::vector<LoopThread> threads(2);
int next_loop=0;
uint64_t  _conn_id=0;
EventLoop base_loop;
LoopThreadPool* pool=nullptr;
std::unordered_map<uint64_t,PtrConnetcion>_conns;
void OnMessage(const PtrConnetcion&con,Buffer*data){
 DBG_LOG("Recv data: %s",data->ReadPosition());
 data->MoveReadOffset(data->ReadAbleSize());
std::string s=" I love you";
 con->Send(s.c_str(),s.size());
}
void OnConnected(const PtrConnetcion& connection){
    DBG_LOG("New connection from %d",connection->Id());
}

void OnClosed(const PtrConnetcion& connection){
    DBG_LOG("Connection %d closed",connection->Id());
}



int main(){
    TcpServer server(8500);
    server.SetThreadCount(2);
    // server.EnableInactiveRelease(10);
    server.SetClosedCallBack(OnClosed);
    server.SetConnectedCallBack(OnConnected);    
    server.SetMessageCallBack(OnMessage);
    // server.DisableInactiveRelease();
    server.Start();
}